package main

import (
	"os"

	"gitee.com/zh-jn/harmonica-previewer-online/api"
	"gitee.com/zh-jn/harmonica-previewer-online/previewer/harmonica/v1/sidecar"
)

func CollectConfigFromEnv() sidecar.Config {
	return sidecar.Config{
		Addr:          api.ParseString(os.Getenv("Sidecar_Addr"), "0.0.0.0"),
		Port:          api.ParseIntValue(os.Getenv("Sidecar_Port"), 8084),
		PreviewerPort: api.ParseIntValue(os.Getenv("Sidecar_PreviewerPort"), 80),
		JsBundlePath:  api.ParseString(os.Getenv("Sidecar_JsBundlePath"), "/data/jsBundles"),
	}
}

func main() {
	cfg := CollectConfigFromEnv()
	sidecar.RunServer(cfg)
}
